To maintain full compatibility with the old Lua runtime, templates
rendered from a menu `template()` action must implicitly inherit the
`luci.dispatcher` namespace as scope while other indirectly included
templates must not.
Fixes: #6105
Signed-off-by: Jo-Philipp Wich <[email protected]>
function run_action(request_path, lang, tree, resolved, action) {
switch (action?.type) {
case 'template':
- runtime.render(action.path, {});
+ render_action(() => {
+ runtime.call('luci.dispatcher', 'render_lua_template', action.path);
+ });
break;
case 'view':
_G.L.include("footer")
end
+function render_lua_template(path)
+ local tpl = require "luci.template"
+
+ tpl.render(path, getfenv(1))
+end
+
function call(name, ...)
return {
elseif key == "resource" then
return L.config.main.resourcebase
else
- return rawget(tbl, key) or disp[key] or _G[key] or L[key]
+ return rawget(tbl, key) or _G[key] or L[key]
end
end})